
<style type="text/css">
    @media (max-width: 375px) {
        .edit-form tr td input {
            width: 100%;
        }
    }
    .string   { color: green; }
    .number   { color: darkorange; }
    .boolean  { color: blue; }
    .null     { color: magenta; }
    .key      { color: red; }
</style>
<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        <div class="panel-lead" style="line-height: 22px;">
            <em>{:__('Warning')}</em>
            快递鸟接口：目前“百世快递、申通快递、天天快递”不支持免费查询。<br/>
            快递100接口：您可根据需求申请/购买快递100账号，使用免费接口和企业接口。
        </div>
        <ul class="nav nav-tabs">
            <li class="active"><a href="#edit" data-toggle="tab">物流接口配置</a></li>
            <li><a href="#demo" data-toggle="tab">接口测试</a></li>
            <li><a href="#help" data-toggle="tab">使用说明</a></li>
        </ul>
    </div>

    <div class="panel-body" style="padding-bottom: 0;">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane active" id="edit">
                <div class="widget-body no-padding">
                    <form id="edit-form" class="edit-form form-horizontal" role="form" data-toggle="validator" method="POST" action="">
                        {:token()}
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th width="15%">{:__('Title')}</th>
                                <th width="85%">{:__('Value')}</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>{:__('Express_type')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <div class="radio">
                                                {foreach name="expressTypeList" item="vo"}
                                                <label for="row[express_type]-{$key}">
                                                    <input id="row[express_type]-{$key}" {in name="key" value="$row.express_type"}class="express_type" checked="checked"{/in} name="row[express_type]" type="radio" value="{$key}"> {$vo}
                                                </label>
                                                {/foreach}
                                            </div>
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>

                            <tr class="kuaidiniao" style="display: none">
                                <td>{:__('Express_bird_userid')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <input id="c-express_bird_userid" class="form-control" name="row[express_bird_userid]" type="text" value="{$row.express_bird_userid|htmlentities}">
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>

                            <tr class="kuaidiniao" style="display: none">
                                <td>{:__('Express_bird_apikey')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <input id="c-express_bird_apikey" class="form-control" name="row[express_bird_apikey]" type="text" value="{$row.express_bird_apikey|htmlentities}">
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>

                            <tr class="kuaidiniao" style="display: none">
                                <td>{:__('Express_bird_customer_name')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <input id="c-express_bird_customer_name" class="form-control" name="row[express_bird_customer_name]" type="text" value="{$row.express_bird_customer_name|htmlentities}" placeholder="若您使用京东物流，则需填写‘京东商家编码’，否则将会造成物流信息无法查询">
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>

                            <tr class="kuaidi100" style="background-color: #fff!important;display: none">
                                <td>{:__('Kuaidi100_type')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <div class="radio">
                                                {foreach name="kuaidi100TypeList" item="vo"}
                                                <label for="row[kuaidi100_type]-{$key}">
                                                    <input id="row[kuaidi100_type]-{$key}" {in name="key" value="$row.kuaidi100_type"}checked="checked" class="kuaidi100_type" {/in} name="row[kuaidi100_type]" type="radio" value="{$key}"> {$vo}
                                                </label>
                                                {/foreach}
                                            </div>
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>

                            <tr class="kuaidi100" style="display: none">
                                <td>{:__('Apikey')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <input id="c-apikey" class="form-control" name="row[apikey]" type="text" value="{$row.apikey|htmlentities}">
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>

                            <tr class="kuaidi100_customer" style="display: none">
                                <td>{:__('Customer')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <input id="c-customer" class="form-control" name="row[customer]" type="text" value="{$row.customer|htmlentities}">
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>

                            <tr class="ali" style="display: none">
                                <td>{:__('Aliappcode')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <input id="c-aliappcode" class="form-control" name="row[aliappcode]" type="text" value="{$row.aliappcode|htmlentities}">
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>

                            <tr>
                                <td>{:__('Express_bird_cache')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <input id="c-express_bird_cache" class="form-control" name="row[express_bird_cache]" type="number" value="{$row.express_bird_cache|htmlentities}">
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                            <tfoot>
                            <tr>
                                <td></td>
                                <td>
                                    <button type="submit" class="btn btn-success btn-embossed">{:__('OK')}</button>
                                    <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
                                </td>
                                <td></td>
                                <td></td>
                            </tr>
                            </tfoot>
                        </table>
                    </form>
                </div>
            </div>
            <div class="tab-pane " id="demo">
                <div class="widget-body no-padding">
                    <form id="demo-form" class="demo-form form-horizontal" role="form" data-toggle="validator" method="POST" action="expressquery/demo">
                        {:token()}
                        <table class="table table-striped" style="width: 40%;">
                            <thead>
                            <tr>
                                <th width="25%">{:__('Title')}</th>
                                <th width="75%">{:__('Value')}</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>{:__('快递公司')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <select  data-rule="required" class="form-control" name="row[express]">
                                                <option value="">请选择</option>
                                                {foreach name="expressList" item="vo"}
                                                <option value="{$vo.express}">{$vo.name}</option>
                                                {/foreach}
                                            </select>
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>{:__('快递单号')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <input class="form-control" name="row[expresssn]" type="text" value="">
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>{:__('收/寄件人电话')}</td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-8 col-xs-12">
                                            <input class="form-control" name="row[phone]" type="text" value="">
                                        </div>
                                        <div class="col-sm-4"></div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <div class="row">
                                        <div class="col-sm-12 col-xs-12" style="color: #999">
                                            收、寄件人的电话号码（手机和固定电话均可，只能填写一个，顺丰速运、顺丰快运必填，其他快递公司选填。
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <button type="submit" class="btn btn-success btn-embossed">{:__('OK')}</button>
                                    <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th width="25%">{:__('响应输出')}</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td style="height: 600px;background-color: #fff;border-left: 1px solid #f4f4f4;"><pre id="express_content"></pre></td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
            <div class="tab-pane " id="help">
                <div class="widget-body no-padding">
                    <pre>
/**
 * 测试物流查询接口
 * @param $params['express']        物流公司编码，这里传进来的是express数据表中的express字段值
 * @param $params['expresssn']      物流单号
 * @author Created by Xing <464401240@qq.com>
 */
public function demo()
{
    if ($this->request->isPost()) {
        $params = $this->request->post("row/a");
        if ($params) {
            //在需要查询物流接口的地方使用以下两行代码即可返回数据
            $expModle = new \addons\expressquery\library\Expressquery();
            //$params['express']   物流公司编码
            //$params['expresssn'] 物流单号
            $list = $expModle->getExpressList($params['express'], $params['expresssn'], $params['phone']);
            return json($list);
        }
    }
    $this->error(__('An unexpected error occurred', ''));
}
                    </pre>
                </div>
            </div>
        </div>
    </div>
</div>
